package com.lemt.sunmao.controller;

import com.lemt.sunmao.domain.User;
import com.lemt.sunmao.response.ResponstData;
import com.lemt.sunmao.service.UserClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 服务消费者
 * */
@RestController
@RequestMapping("/consumer")
@CrossOrigin //解决跨域问题
public class UserConsumerController {
    @Autowired
    private UserClientService userClientService;

    @GetMapping("/findPageUsers")
    public ResponstData findPageUsers(String username,Integer currentPage, Integer pageSize){
        return userClientService.findPageUsers(username,currentPage,pageSize);
    }

    @GetMapping("/{id}")
    public ResponstData getById(@PathVariable("id") Long id){
        return userClientService.getById(id);
    }

    @DeleteMapping("/{id}")
    public ResponstData deleteById(@PathVariable("id") Long id){
        return userClientService.deleteById(id);
    }

    @PostMapping
    public ResponstData save(@RequestBody User user){
        return userClientService.save(user);
    }
}
